package com.example.fengyungo.util;

import com.example.fengyungo.domain.pojo.LoginUser;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class AdminUtil {

    public static String getCurrentAdminId() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (!(authentication instanceof AnonymousAuthenticationToken)) {
            LoginUser loginUser = (LoginUser) authentication.getPrincipal();
            return loginUser.getAdmin().getAdminId();
        }
        return null;
    }
}
